class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        string ret=strs[0];
        for(int i=1;i<strs.size();i++)
            ret=findCommon(ret,strs[i]);
        return ret;
    }
    string findCommon(string& s1,string& s2)
    {
        int i=0;
        while(i<min(s1.size(),s2.size())&&s1[i]==s2[i])i++;
        return s1.substr(0,i);
    }
};
